<!--
 * @Description:闭包onresize
 * @Author: Sun
 * @Date: 2019-07-01 20:05:50
 * @LastEditors: Sun
 * @LastEditTime: 2019-07-28 07:54:03
 -->
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>闭包onresize</title>
	<style>
		* {
			margin: 0;
			padding: 0
		}

		ul {
			list-style: none;
		}

		div {
			width: 1004px;
			height: 350px;
			margin: 50px auto;
			overflow: hidden;
		}

		div li {
			width: 200px;
			height: 350px;
			float: left;
			margin-left: -1px;
			background-size: cover;
			overflow: hidden;
		}

		#dv ul {
			width: 1004px;
		}
	</style>
</head>

<body>
	<div id="dv">
		什么是闭包<br>
		白话：我们可以用一个函数取访问另外一个函数变量的方式就是闭包<br>
		内部变量是局部变量<br>
		把我们就知道 局部变量是不可以为别人随意使用的
	</div>
	<script>
		window.onload = function () {
			window.onresize = throttle(ss,400)

			function ss() {
				let yu = window.innerWidth || document.documentElement.clientWidth;
				console.log(yu) //屏幕宽度
			}

			function throttle(fn,delay) {
				var timer = null;
				return function () {
					clearTimeout(timer)
					timer = setTimeout(fn,delay)
				}
			}

		}
	</script>

</body>

</html>